{include file="base/_meta" /}
</head>
<body>

<!-- 正文开始 -->
<div class="layui-fluid layui-form">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">

                <input type="hidden" name="id" value="{$data.id|default=''}">
                <input type="hidden" name="admin_id" value="{$data.admin_id|default=''}">

                <div class="layui-col-sm6">

                    <div class="layui-form-item">
                        <label class="layui-form-label">所属分类:</label>
                        <div class="layui-input-block">
                            <select name="shop_cate_id">
                                <option></option>
                                {notempty name="shopCate"}
                                    {volist name="shopCate" id="voShopCate"}
                                        <option value="{$voShopCate.id}" {notempty name="$data.shop_cate_id"}{eq name="$data.shop_cate_id" value="$voShopCate.id"} selected{/eq}{/notempty}>{$voShopCate.name}</option>
                                    {/volist}
                                {/notempty}

                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">名称:</label>
                        <div class="layui-input-block">
                            <input name="name" placeholder="请输入名称" class="layui-input"
                                   lay-verType="tips" lay-verify="required" required autocomplete="off" value="{$data.name|default=''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">电话:</label>
                        <div class="layui-input-block">
                            <input name="phone" placeholder="请输入联系电话" class="layui-input"
                                   lay-verType="tips" lay-verify="required" required autocomplete="off" value="{$data.phone|default=''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">账号:</label>
                        <div class="layui-input-block">
                            <input name="username" placeholder="请输入账号" class="layui-input"
                                   lay-verType="tips" lay-verify="required" required autocomplete="off" value="{$data.username|default=''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">密码:</label>
                        <div class="layui-input-block">
                            <input name="password" placeholder="请输入密码" class="layui-input"
                                   lay-verType="tips" lay-verify="required" required autocomplete="off" value="{$data.password|default=''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">排序:</label>
                        <div class="layui-input-block">
                            <input name="sort" placeholder="请输入名称" class="layui-input" required autocomplete="off" type="number" value="{$data.sort|default='0'}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">状态:</label>
                        <div class="layui-input-block">
                            <input type="radio" name="show" value="10" title="显示" {notempty name="$data.show"}{neq name="$data.show" value="20"}checked{/neq}{else}checked{/notempty}>
                            <input type="radio" name="show" value="20" title="隐藏" {notempty name="$data.show"}{eq name="$data.show" value="20"}checked{/eq}{/notempty}>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">置顶:</label>
                        <div class="layui-input-block">
                            <input type="radio" name="top" value="10" title="置顶" {notempty name="$data.top"}{neq name="$data.top" value="20"}checked{/neq}{else}checked{/notempty}>
                            <input type="radio" name="top" value="20" title="不置顶" {notempty name="$data.top"}{eq name="$data.top" value="20"}checked{/eq}{/notempty}>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">简介:</label>
                        <div class="layui-input-block">
                            <textarea name="desc" placeholder="请输入" class="layui-textarea">{$data.desc|default=''}</textarea>
                        </div>
                    </div>

                </div>

                <div class="layui-col-sm6">

                    <div class="layui-form-item">
                        <label class="layui-form-label">缩略图：</label>
                        <div class="layui-input-block">
                            <div class="layui-upload-drag" id="img_thumb" onclick="upload_file('img_thumb',1)">
                                <div>
                                    <img src="{$data.img_thumb|default='/static/images/default_img.png'}"
                                         alt="上传成功后渲染" style="max-width: 96px">
                                    <input type="hidden" name="img_thumb" value="{$data.img_thumb|default=''}">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">轮播图：</label>
                        <div class="layui-input-block carouselDiv">
                            <!--多文件上传-->
                            <button type="button" class="layui-btn layui-btn-normal" id="carousel"
                                    onclick="upload_file('carousel',5)">选择多文件
                            </button>
                            <div class="layui-upload-list">
                                <!--上传文件列表-->
                                <div class="img-div layui-clear">
                                    {notempty name="$data.carousel"}
                                    <?php $carousel = explode(',',$data['carousel']);?>
                                        {volist name="carousel" id="voCarousel"}
                                            <div class='pull-left upload-img-div'><img src='{$voCarousel}' width='100%'/><i class='layui-icon layui-icon-close-fill upload-file-del'></i></div>
                                        {/volist}
                                    {/notempty}
                                </div>
                                <!--隐藏域，放文件路径使用-->
                                <input type="hidden" name="carousel" value="{$data.carousel|default=''}">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">选择地图：</label>
                        <div class="layui-input-block carouselDiv">
                            <button type="button" class="layui-btn layui-btn-normal" id="chooseLocation">选择地图</button>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">省市区:</label>
                        <div class="layui-input-inline" style="width: 120px;">
                            <input name="province" id="province" class="layui-input" required autocomplete="off" value="{$data.province|default=''}"/>
                        </div>
                        <div class="layui-input-inline" style="width: 120px;">
                            <input name="city" id="city" class="layui-input" required autocomplete="off" value="{$data.city|default=''}"/>
                        </div>
                        <div class="layui-input-inline" style="width: 120px;">
                            <input name="area" id="area" class="layui-input" required autocomplete="off" value="{$data.area|default=''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">详细地址:</label>
                        <div class="layui-input-block">
                            <input name="address" id="address" class="layui-input" required autocomplete="off" value="{$data.address|default=''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">经纬度:</label>
                        <div class="layui-input-inline">
                            <input name="lat" id="lat" class="layui-input" required autocomplete="off" value="{$data.lat|default=''}"/>
                        </div>
                        <div class="layui-input-inline">
                            <input name="lng" id="lng" class="layui-input" required autocomplete="off" value="{$data.lng|default=''}"/>
                        </div>
                    </div>
                </div>

                <div class="layui-col-sm12">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">内容:</label>
                        <div class="layui-input-block">
                            <script id="container" name="content" type="text/plain">{notempty name="$data.content"}{:html_entity_decode($data.content)}{/notempty}</script>
                        </div>
                    </div>

                </div>

                <div class="layui-form-item">
                    <button class="layui-btn" lay-filter="authoritiesEditSubmit" lay-submit>保存</button>
                </div>

            </div>
        </div>
    </div>
</div>

<!-- js部分 -->
{include file="base/_script" /}
<!-- 配置文件 -->
<script type="text/javascript" src="__LIB__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__LIB__/ueditor/ueditor.all.js"></script>
<script>
    layui.use(['layer', 'form', 'admin','xmSelect'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var xmSelect = layui.xmSelect;

        var ue = UE.getEditor('container',{
            initialFrameHeight:500,
            wordCount:false,
        });

        /* 监听表单提交 */
        form.on('submit(authoritiesEditSubmit)', function (data) {
            data.field.content = ue.getContent();
            $.get("{:url('shop/shop_save')}", data.field, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 1,time:1000},function () {
                        admin.closeThisTabs()
                    });
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');
            return false;
        });

        // 选择地图
        $("#chooseLocation").click(function () {
            admin.chooseLocation({
                needCity: true,
                onSelect: function (res) {
                    $("#province").val(res.city.province)
                    $("#city").val(res.city.city)
                    $("#area").val(res.city.district)
                    $("#address").val(res.address)
                    $("#lat").val(res.lat)
                    $("#lng").val(res.lng)
                }
            });
        })
    });
</script>
</body>
</html>
